#include "thread_pool.h"
#include <stdio.h>
#include <Windows.h>
#include <vld.h>

void print_message(void* arg) {
    printf("Thread %ld: %s\n", GetCurrentThreadId(), (char*)arg);
    Sleep(1);
    free(arg);
}

int main(int argc, char* argv[]) {
    thread_pool_t* pool = thread_pool_create(4);
    if (pool == NULL) {
        fprintf(stderr, "Failed to create thread pool\n");
        return 1;
    }

    Sleep(10);

    for (int i = 0; i < 200; i++) {
        Sleep(1);
        char* message = (char*)malloc(50);
        snprintf(message, 50, "Hello from task %d", i+1);
        thread_pool_submit(pool, print_message, message);
    }

    //Sleep(2);
    printf("thread_pool_destroy(): enter...\n");
    thread_pool_destroy(pool);
    printf("thread_pool_destroy(): leave...\n");
    return 0;
}
